package com.demo3;

import java.util.Scanner;

/**
 * 椭圆
 * @author J.L.Zhou
 *	jlzhou.top 版权所有
 */
public class Ellipse extends AbstractShape {
	/**
	 * 宽
	 */
	private float a;
	/**
	 * 高
	 */
	private float b;


	public Ellipse(){
		super("椭圆形");
	}
	protected Ellipse(String name){
		super(name);
	}


	@Override
	public void inputBaseInfo(Scanner sc) {
		System.out.println("输入"+getName()+"的最长半径: ");
		a = sc.nextFloat();

		System.out.println("输入"+getName()+"的最短半径: ");
		b = sc.nextFloat();

		if(b>a){
			float temp = a;
			a = b;
			b = temp;
		}
	}

	@Override
	public float calcArea() {
		return (float)(Math.PI*a*b);
	}

	@Override
	public float caclPerimeter() {
		return (float)(2*Math.PI*b+4*(a-b));
	}


	@Override
	public String getBaseInfo() {
		return String.format("半径：%.2f，%.2f",a,b);
	}


	public float getA() {
		return a;
	}


	public void setA(float a) {
		this.a = a;
	}


	public float getB() {
		return b;
	}


	public void setB(float b) {
		this.b = b;
	}


	public static void main(String[] args) {
		Ellipse rectangle = new Ellipse();
		rectangle.input(new Scanner(System.in));
		rectangle.show();
	}

}
